
	mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					up: {
						auto:false,
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
	});
	
	
	var userinfo = app.getState() || {};
    var uid = userinfo.user_id;
    var currenPage=1;
    var pageSize=15;
    var total_page=0;
    var total_count=0;
    var user_ids='';
    
    window.onload = function(){
    	console.log(JSON.stringify(userinfo.token));
    	
    	mui.ajax({
				url: apiurl + "Article/book_ulist/",
				data: {'p':currenPage,'size':pageSize,'_token':userinfo.token},
				async: true,
				dataType: 'json',
				crossDomain: true, //强制使用5+跨域
				type: 'get',
				timeout: 10000,
				success: function(res) {
					console.log(JSON.stringify(res));
					// 请求成功
					if(res.status ==-3){
						mui.toast(res.msg);
						app.out();
						return false;
					} else {
						total_page=res.total_page;
						total_count=res.sum;
						user_ids=res.user_ids;
						var htm=get_data(res.resource);
						$('#pullrefresh .mui-scroll .mui-table-view').append(htm);
					}
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('获取数据失败！');
				}
			});
			
			 mui.plusReady(function(){
			    //关闭等待框
			    plus.nativeUI.closeWaiting();
			    //显示当前页面
			    mui.currentWebview.show();
			    
			   mui(".mui-table-view").on('tap','.mui-table-view-cell .see_user_new',function(){
				  //获取id
				  var id = this.getAttribute("data-id");
				  var name= this.getAttribute("data-name");
				  //打开来自会员消息详情页
				  mui.openWindow({
					    id:'user_news_detail.html',
					    url:'user_news_detail.html',
					    extras:{
						    other_id: id,  //自定义扩展参数，可以用来处理页面间传值
						    other_name: name
						},
					    show: {
							autoShow:false
						},
						waiting:{
					       autoShow:true,//自动显示等待框，默认为true
					       title:'正在加载...'//等待对话框上显示的提示内容
					    }
				   });
				 
				}) 

			});

    }

    function get_data(data){
    	var htm='';
		for(i in data) {
			/*
			 * <li class="mui-table-view-cell">
								<a class="mui-navigate-right" id="add_shop" lang>
									会员：小明（ID：1234）
								</a>
							</li>
			 */
			htm+='<li class="mui-table-view-cell">';
			htm+='<a class="mui-navigate-right see_user_new" data-id="'+data[i]['user_id']+'" data-name="'+data[i]['nickname']+'">';
			htm+='会员：'+data[i]['nickname']+'（ID：'+data[i]['user_id']+'）';
			htm+='</a>';
			htm+='</li>';
		}
		return htm;
    }


	function pullupRefresh() {
		setTimeout(function() {
			currenPage++;
			mui.ajax({
				url: apiurl + "Article/book_ulist//",
				data: {'p':currenPage,'size':pageSize,'_token':userinfo.token,'user_ids':user_ids},
				async: true,
				dataType: 'json',
				crossDomain: true, //强制使用5+跨域
				type: 'get',
				timeout: 10000,
				success: function(res) {
					console.log(JSON.stringify(res));
					// 请求成功
					if(res.status ==-3){
						mui.toast(res.msg);
						app.out();
						return false;
					} else {
						var htm=get_data(res.resource);
						$('#pullrefresh .mui-scroll .mui-table-view').append(htm);
					}
					
					if(currenPage < total_page){
	                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);    /*能上拉*/
	                }else{
	                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);/*不能上拉*/
	                }
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('获取数据失败！');
				}
			});
			
		}, 1500);
	}
	
	
	
